﻿@using CodeCamp.Models.EventMgmt
@model EventMgmtUsersViewModel
@{
    Layout = "~/Views/Shared/_LayoutWideSimple.cshtml";
    @* ViewBag.RegistrationUrl set in code - SetSharedViewBagProperties *@
    ViewBag.EventName = "";
    ViewBag.Title = "";
    if ((@Model != null) && (@Model.EventDisplayName != null))
    {
        ViewBag.Title = @Html.Encode(@Model.EventDisplayName + " | Presenters");
        ViewBag.EventName = @Model.EventDisplayName;
    }
    else
    {
        ViewBag.Title = "Code Camp | Presenters";
        ViewBag.EventName = "Code Camp";
    }
}

@section headaddon {
<style>
    table
    {
        border-collapse: collapse;
        border: solid 1px;
        margin: 0;
    }
    th
    {
        padding: 4px;
    }
    td 
    {
        padding: 4px;
    }
    #content
    {
        width: 900px;
    }
    td.datetime-nowrap
    {
        white-space:nowrap;
    }
</style>
}

<div>
<h2 class="title">@ViewBag.Title</h2>

<table>
    <tbody>
        <tr><th>Presenter</th><th># Ses</th><th># PR Emails</th><th># SU Emails</th><th>User</th><th>Created<br />u / p</th><th>Locked<br />Out</th><th>Online</th><th>Last Login (UTC)</th><th>Last Activity (UTC)</th></tr>
        @foreach (EventMgmtUserViewModel user in @Model.UserList)
        {
            <tr>
            <td>
                @if (@user.PresenterId.HasValue && @user.PresenterId.Value != 0)
                {
                    @Html.ActionLink(@user.PresenterName, "Details", "Presenters", new { id = @user.PresenterId.Value }, null)<text>&nbsp;</text><br />
                    @user.PresenterEmailAddress
                }
            </td>
            <td>@user.SessionCount</td>
            <td>@user.PresenterEmailCount</td>
            <td>@user.SiteUserEmailCount</td>
            <td>
                @*@user.Username<br />
                @user.UserEmailAddress*@
                @Html.ActionLink("Site user", "SiteUserDetail", new { eventName = Model.EventShortName, id = user.SiteUserId })
            </td>
            <td class="datetime-nowrap">@string.Format("{0:yyyy-MM-dd}", user.UserCreationDate)<br />@string.Format("{0:yyyy-MM-dd}", user.PresenterCreationDate)</td>
            <td>@if (user.IsLockedOut) { <text>Locked</text> } else {<text>&nbsp;</text>}</td>
            <td>@if (user.IsOnline) { <text>Online</text> } else {<text>&nbsp;</text>}</td>
            <td class="datetime-nowrap">@if (@user.LastLoginDate.HasValue)
                { <text>@user.LastLoginDate.Value.ToString("yyyy-MM-dd  HH:mm")</text> }
                else
                { <text>&nbsp;</text> }</td>
            <td>@string.Format("{0:yyyy-MM-dd  HH:mm}", user.LastActivityDate)</td> @* LastActivityDate seems to always be same as LastLoginDate *@
            </tr>
        }
        <tr><td colspan="8">Page @Model.PageNumber of @Model.TotalPages
        @if (@Model.TotalPages > (Decimal)1.0)
        {
            <b>Time to add paging!</b>
        }
        </td></tr>
    </tbody>
</table>
</div>

@section sidebar {
    <div id="subLinksContainer" class="widget rounded-10">
    <h3>Event Mgmt</h3>
    <ul>
        <li>@Html.ActionLink("Mgmt Home", "Index", "EventMgmt", new { eventName = Model.EventShortName }, null)</li>
        <li>@Html.ActionLink("EMail", "Index", "Email", new { eventName = Model.EventShortName }, null)</li>
        <li>@Html.ActionLink("Logs", "List", "Logs", new { eventName = Model.EventShortName }, null)</li>
        <li>@Html.ActionLink("Site Users", "SiteUsers", "EventMgmt", new { eventName = Model.EventShortName }, null)</li>
        <li>@Html.ActionLink("Sponsors", "SponsorsList", "EventMgmt", new { eventName = Model.EventShortName }, null)</li>
    </ul>
    </div>
}